home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / FPTDIV < prev    next >
Encoding:
Text File  |  1985-12-25  |  1.6 KB  |  62 lines

  1. ;-------------------------fptdiv routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 86
  4. ;
  5. ; NAME FPTDIV
  6. ; ROUTINE FOR DIVISION OF TEMPORARY FLOATING POINT NUMBER BY 10
  7. ;
  8. ; FUNCTION: This routine divides a temporary binary floating point
  9. ; number by 10.
  10. ;
  11. ; INPUT: Upon entry DS:DI points to a temporary binary floating point
  12. ; number.
  13. ;
  14. ; OUTPUT: Upon exit DS:DI points to a temporary binary floating
  15. ; point number.
  16. ;
  17. ; REGISTERS USED:  AX,CX,DX and DI are modified.  DI must point to the
  18. ; input.
  19. ;
  20. ; SEGMENTS REFERENCED:  The data segment must contain the temporary
  21. ; binary floating point number.
  22. ;
  23. ; ROUTINES CALLED:  None
  24. ; SPECIAL NOTES: Equates are used to shorten address fields.  This is a
  25. ; near procedure needed by FPIN.
  26. ;
  27. ; ROUTINE TO DIVIDE TEMP FLOATING POINT NUMBER BY 10.  RESULT IS NOT
  28. ; NORMALIZED.
  29. ;
  30. fptdiv    proc    near
  31. ;
  32. ; shift mantissa by 4 places
  33.     mov    cx,4        ; for a count of four
  34. fptdiv1:
  35.     sal    diword+0,1    ; shift left all digits
  36.     rcl    diword+2,1    ; carry on
  37.     rcl    diword+4,1
  38.     rcl    diword+6,1
  39.     rcl    diword+8,1
  40.     dec    diword+11    
  41.     loop    fptdiv1
  42. ;
  43. ; divide mantissa by 10
  44.     mov    cx,5        ; 5 words in number
  45.     mov    dx,0        ; previous remainder
  46.     add    di,8        ; point to end
  47. ;
  48. fptdiv2:
  49.     push    cx        ; save count
  50.     mov    ax,[di]        ; get 16-bit digit
  51.     mov    cx,10        ; divisor of 10
  52.     div    cx        ; divide
  53.     mov    [di],ax        ; put 16-digit back
  54.     sub    di,2        ; next 16-bit digit
  55.     pop    cx        ; restore count
  56.     loop    fptdiv2
  57. ;
  58.     ret            ; return
  59. ;    
  60. fptdiv    endp
  61. ;-------------------------fptdiv routine ends---------------------------+
  62.